package 剑指Offer;

/**
 * @Author cheng.song
 * @create 2021/11/9 10:41
 */
public class Offer05替换空格 {
    public static void main(String[] args) {
        System.out.println(replaceSpace("We are happy."));
    }


    public static String replaceSpace(String s) {
        StringBuilder builder = new StringBuilder();
        for (char c : s.toCharArray()) {
            if(c==' '){
                builder.append("%20");
            }else{
                builder.append(c);
            }
        }
        return builder.toString();
    }
}
